}
$this->setVar( '_Extensions', $status->value );
} elseif ( isset( $options['with-extensions'] ) ) {
- $this->setVar( '_Extensions', array_keys( $this->findExtensions() ) );
+ $status = $this->findExtensions();
+ if ( !$status->isOK() ) {
+ throw new InstallException( $status );
+ }
+ $this->setVar( '_Extensions', array_keys( $status->value ) );
}
// Set up the default skins
}
$skins = $status->value;
} else {
- $skins = array_keys( $this->findExtensions( 'skins' ) );
+ $status = $this->findExtensions( 'skins' );
+ if ( !$status->isOK() ) {
+ throw new InstallException( $status );
+ }
+ $skins = array_keys( $status->value );
}
$this->setVar( '_Skins', $skins );
*
* @param string $directory Directory to search in, relative to $IP, must be either "extensions"
* or "skins"
- * @return array[][] [ $extName => [ 'screenshots' => [ '...' ] ]
+ * @return Status An object containing an error list. If there were no errors, an associative
+ * array of information about the extension can be found in $status->value.
*/
public function findExtensions( $directory = 'extensions' ) {
switch ( $directory ) {
*
* @param string $type Either "extension" or "skin"
* @param string $directory Directory to search in, relative to $IP
- * @return array [ $extName => [ 'screenshots' => [ '...' ] ]
+ * @return Status An object containing an error list. If there were no errors, an associative
+ * array of information about the extension can be found in $status->value.
*/
protected function findExtensionsByType( $type = 'extension', $directory = 'extensions' ) {
if ( $this->getVar( 'IP' ) === null ) {
- return [];
+ return Status::newGood( [] );
}
$extDir = $this->getVar( 'IP' ) . '/' . $directory;
if ( !is_readable( $extDir ) || !is_dir( $extDir ) ) {
- return [];
+ return Status::newGood( [] );
}
$dh = opendir( $extDir );
$exts = [];
+ $status = new Status;
while ( ( $file = readdir( $dh ) ) !== false ) {
- if ( !is_dir( "$extDir/$file" ) ) {
+ // skip non-dirs and hidden directories
+ if ( !is_dir( "$extDir/$file" ) || $file[0] === '.' ) {
continue;
}
- $status = $this->getExtensionInfo( $type, $directory, $file );
- if ( $status->isOK() ) {
- $exts[$file] = $status->value;
+ $extStatus = $this->getExtensionInfo( $type, $directory, $file );
+ if ( $extStatus->isOK() ) {
+ $exts[$file] = $extStatus->value;
+ } elseif ( $extStatus->hasMessage( 'config-extension-not-found' ) ) {
+ // (T225512) The directory is not actually an extension. Downgrade to warning.
+ $status->warning( 'config-extension-not-found', $file );
+ } else {
+ $status->merge( $extStatus );
}
}
closedir( $dh );
uksort( $exts, 'strnatcasecmp' );
- return $exts;
+ $status->value = $exts;
+
+ return $status;
}
/**
} elseif ( $e->missingExtensions || $e->missingSkins ) {
// There's an extension missing in the dependency tree,
// so add those to the dependency list and try again
- return $this->readExtension(
+ $status = $this->readExtension(
$fullJsonFile,
array_merge( $extDeps, $e->missingExtensions ),
array_merge( $skinDeps, $e->missingSkins )
);
+ if ( !$status->isOK() && !$status->hasMessage( 'config-extension-dependency' ) ) {
+ $status = Status::newFatal( 'config-extension-dependency',
+ basename( dirname( $fullJsonFile ) ), $status->getMessage() );
+ }
+ return $status;
}
// Some other kind of dependency error?
return Status::newFatal( 'config-extension-dependency',
$this->getFieldsetEnd()
);
- $skins = $this->parent->findExtensions( 'skins' );
+ $skins = $this->parent->findExtensions( 'skins' )->value;
+ '@phan-var array[] $skins';
$skinHtml = $this->getFieldsetStart( 'config-skins' );
$skinNames = array_map( 'strtolower', array_keys( $skins ) );
$this->getFieldsetEnd();
$this->addHTML( $skinHtml );
- $extensions = $this->parent->findExtensions();
+ $extensions = $this->parent->findExtensions()->value;
+ '@phan-var array[] $extensions';
$dependencyMap = [];
if ( $extensions ) {
return null;
}
+ /**
+ * @param string $name
+ * @param array $screenshots
+ */
private function makeScreenshotsLink( $name, $screenshots ) {
global $wgLang;
if ( count( $screenshots ) > 1 ) {
$links = [];
$counter = 1;
+
foreach ( $screenshots as $shot ) {
$links[] = Html::element(
'a',
* @return bool
*/
public function submitSkins() {
- $skins = array_keys( $this->parent->findExtensions( 'skins' ) );
+ $skins = array_keys( $this->parent->findExtensions( 'skins' )->value );
$this->parent->setVar( '_Skins', $skins );
if ( $skins ) {
$this->setVar( 'wgRightsIcon', '' );
}
- $skinsAvailable = array_keys( $this->parent->findExtensions( 'skins' ) );
+ $skinsAvailable = array_keys( $this->parent->findExtensions( 'skins' )->value );
$skinsToInstall = [];
foreach ( $skinsAvailable as $skin ) {
$this->parent->setVarsFromRequest( [ "skin-$skin" ] );
$retVal = false;
}
- $extsAvailable = array_keys( $this->parent->findExtensions() );
+ $extsAvailable = array_keys( $this->parent->findExtensions()->value );
$extsToInstall = [];
foreach ( $extsAvailable as $ext ) {
$this->parent->setVarsFromRequest( [ "ext-$ext" ] );